package de.alexhepp.widgets.messagewidget;

import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
import android.os.Handler;

public class SMSObserver extends ContentObserver {

	private Context context;
	
	private static final String TAG = "SMSObserver";

	public SMSObserver(Handler handler) {
		super(handler);
	}

	public void setContext(Context context) {
		this.context = context;
	}

	@Override
	public boolean deliverSelfNotifications() {
		return false;
	}

	@Override
	public void onChange(boolean selfNotification) {
		super.onChange(selfNotification);

//		Log.v(TAG, "Notification on SMS observer");

		Intent updateServiceIntent = new Intent(context, MessageWidget.UpdateService.class);
		updateServiceIntent.putExtra("receivedSMS", false);
		
		context.startService(updateServiceIntent);
	}
}
